import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
    // //地址为空时跳转home页面
    // {
    //     path: '',
    //     redirect: '/'
    // },
  {
      path: '/',
      component: () => import('../views/Layout.vue'),
      children: [
          {
            path: '',
            component: () => import('../views/Home.vue'),
              meta: {
                  title:"Home Page"
              }
          },
          {
              path: 'apnSetting',
              component: () => import('../views/Wan/ApnSetting'),
              meta: {
                  module:"metaWan",
                  title:"apnSetting Page"
              }
          },
          {
              path: 'netModeSetting',
              component: () => import('../views/Wan/NetModeSetting'),
                meta: {
                    module:"metaWan",
                    title:"netModeSetting Page"
                }
          },
          {
              path: 'wlanBasicSetting',
              component: () => import('../views/Wlan/WlanBasicSetting'),
              meta: {
                  module:"metaWlan",
                  title:"metaWlan Page"
              }
          },
          {
              path: 'wlanMacFilterSetting',
              component: () => import('../views/Wlan/WlanMacFilterSetting'),
              meta: {
                  module:"metaWlan",
                  title:"metaWlan Page"
              }
          },
        ]
    },
    {
        path: '/login',
        name: 'Login',
        component: () => import('../views/Login.vue'),
        meta: {
            title:"Login Page"
        }
    },
    {
        path: '*',
        component: () => import('../views/404.vue')
    }
]

const router = new VueRouter({
  routes
})

//导航守卫 to 要去的地方 from 来的地方, next 跳转方法
router.beforeEach((to, from, next) => {
    document.title = to.meta.title;
    next();

    /*setTimeout( () => {
        next();
    }, 5000);*/

})

export default router
